home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Periodicals / CSMP / C.S.M.P. Digest, Issue 3.008 < prev    next >
Internet Message Format  |  1994-06-09  |  29KB

  1. From: pottier@clipper.ens.fr (Francois Pottier)
  2. Subject: csmp-digest-v3-008
  3. Date: Sun, 3 Apr 94 22:39:07 MET DST
  4.  
  5. C.S.M.P. Digest             Sun, 03 Apr 94       Volume 3 : Issue 8
  6.  
  7. Today's Topics:
  8.  
  9.         ?Time manager code for pascal!
  10.         Copying with a mask
  11.         Macsbug for PowerMac?
  12.         Math on PowerMacs (was Re: PowerMac emulate a 68LC040??)
  13.         Passing data through to completion procs?
  14.         Sending AppleEvents To Eudora
  15.  
  16.  
  17.  
  18. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  19. (pottier@clipper.ens.fr).
  20.  
  21. The digest is a collection of article threads from the internet newsgroup
  22. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  23. regularly and want an archive of the discussions.  If you don't know what a
  24. newsgroup is, you probably don't have access to it.  Ask your systems
  25. administrator(s) for details.  If you don't have access to news, you may
  26. still be able to post messages to the group by using a mail server like
  27. anon.penet.fi (mail help@anon.penet.fi for more information).
  28.  
  29. Each issue of the digest contains one or more sets of articles (called
  30. threads), with each set corresponding to a 'discussion' of a particular
  31. subject.  The articles are not edited; all articles included in this digest
  32. are in their original posted form (as received by our news server at
  33. nef.ens.fr).  Article threads are not added to the digest until the last
  34. article added to the thread is at least two weeks old (this is to ensure that
  35. the thread is dead before adding it to the digest).  Article threads that
  36. consist of only one message are generally not included in the digest.
  37.  
  38. The digest is officially distributed by two means, by email and ftp.
  39.  
  40. If you want to receive the digest by mail, send email to listserv@ens.fr
  41. with no subject and one of the following commands as body:
  42.     help                        Sends you a summary of commands
  43.     subscribe csmp-digest Your Name    Adds you to the mailing list
  44.     signoff csmp-digest            Removes you from the list
  45. Once you have subscribed, you will automatically receive each new
  46. issue as it is created.
  47.  
  48. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  49. Questions related to the ftp site should be directed to
  50. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  51. digest are available there.
  52.  
  53. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  54.  
  55.  
  56. -------------------------------------------------------
  57.  
  58. >From dln2@cornell.edu (David Negro)
  59. Subject: ?Time manager code for pascal!
  60. Date: 18 Mar 1994 08:40:11 GMT
  61. Organization: Cornell University
  62.  
  63. Hi,
  64. I was wondering if any of you had any code that I could take a quick look
  65. at on the time manager.  I have the NIM Processes and have tried following
  66. the examples but with no luck whatsoever.  It seems that when I run my test
  67. program to try to learn the time manager, that the program runs, seems to
  68. install the task, and then when it comes time for the task to execute it
  69. CRASHES ;-(
  70. When I pass a nil pointer for the task it seems to work fine as far as I
  71. can tell.  But when I pass a pointer to a procedure  (even one with nothing
  72. in it!) it seems to crash.  I would post what is probably a pitiful piece
  73. of code for some of you to take a look, but at the moment I am so
  74. frustrated with having my sytem crash so many times that I don't want to
  75. look at it myself.  So if anybody out there can just send me a snippet on
  76. how to install a task with instime and primetime I would greatly appreciate
  77. it!
  78.  
  79. Thanks in advance,
  80. Dave Negro
  81. dln2@cornell.edu
  82.  
  83. +++++++++++++++++++++++++++
  84.  
  85. >From zhfzc@zh014.ubs.ubs.ch (Christian Franz)
  86. Date: Fri, 18 Mar 1994 11:17:27 GMT
  87. Organization: Union Bank Switzerland, CH
  88.  
  89. In article 180394033426@j30265153.reslife.cornell.edu, dln2@cornell.edu (David Negro) writes:
  90. >Hi,
  91. >I was wondering if any of you had any code that I could take a quick look
  92. >at on the time manager.  I have the NIM Processes and have tried following
  93. >the examples but with no luck whatsoever.  It seems that when I run my test
  94. >program to try to learn the time manager, that the program runs, seems to
  95. >install the task, and then when it comes time for the task to execute it
  96. >CRASHES ;-(
  97. >When I pass a nil pointer for the task it seems to work fine as far as I
  98. >can tell.  But when I pass a pointer to a procedure  (even one with nothing
  99. >in it!) it seems to crash.  I would post what is probably a pitiful piece
  100. >of code for some of you to take a look, but at the moment I am so
  101. >frustrated with having my sytem crash so many times that I don't want to
  102. >look at it myself.  
  103.  
  104. I wager you are using THINK Pascal and have turned debugging on. That's a 
  105. no-no since the TM callback proc will be called during interrupt-time where
  106. you are not allowed to do anything that moves memory... TP's Debugger does.
  107.  
  108. I've had the same problem and they went away when I switched debugging off
  109. for the callback procedure. 
  110. The catch is of course that you can't debug your callback. So what I did was
  111. to set a 'TimedOut' boolean flag in the callback proc and nothing else.
  112. >From the main program I monitored the timedOut flag and did all processing
  113. the was required when it did. 
  114.  
  115.  
  116. >So if anybody out there can just send me a snippet on
  117. >how to install a task with instime and primetime I would greatly appreciate
  118. >it!
  119.  
  120. Try disabeling debugging. If it still doesn't work, I'll send you some code.
  121.  
  122. >
  123. >Thanks in advance,
  124. >Dave Negro
  125. >dln2@cornell.edu
  126.  
  127. Cheers,
  128. Christian
  129.  
  130.  
  131. --
  132. Christian Franz                        *              Union Bank Of Switzerland
  133. cfranz@home.malg.imp.com         <- at home ->                     +1-261 26 96
  134.  
  135.  
  136. +++++++++++++++++++++++++++
  137.  
  138. >From spector@bach.seattleu.edu (Mitchell S. Spector)
  139. Date: 19 Mar 1994 07:24:34 -0800
  140. Organization: Seattle University, Seattle, Washington, U.S.A.
  141.  
  142. In article <1994Mar18.111727.15370@zh014.ubs.ubs.ch>,
  143. Christian Franz <zhfzc@zh014.ubs.ubs.ch> wrote:
  144.  >In article 180394033426@j30265153.reslife.cornell.edu, dln2@cornell.edu (David Negro) writes:
  145.  >> [Time Manager crashes, even when the task is an empty procedure.]
  146.  >
  147.  >I wager you are using THINK Pascal and have turned debugging on. That's a 
  148.  >no-no since the TM callback proc will be called during interrupt-time where
  149.  >you are not allowed to do anything that moves memory... TP's Debugger does.
  150.  
  151.    Yes.  And, even with debugging off, if you are running your program in the
  152. Think Pascal environment (rather than as a stand-alone application), there
  153. may be a limit on how frequently you can have the Time Manager execute a
  154. task.  This limit will depend on the speed of the computer you are using.
  155. You ought to be safe if you make sure that your period is at least
  156. 1/30 sec; I've been able to use the Time Manager with that period even
  157. on an old Mac II, but 1/60 sec didn't work.  Or else build a stand-alone
  158. application -- you can then use any time interval you want.
  159.  
  160.    Also, be sure that you're setting and restoring A5; Inside Macintosh
  161. shows how to do this.
  162.  
  163.                             Mitchell
  164.  
  165.  
  166.  >>Dave Negro
  167.  >>dln2@cornell.edu
  168.  
  169.  >Christian Franz                        *              Union Bank Of Switzerland
  170.  >cfranz@home.malg.imp.com         <- at home ->                     +1-261 26 96
  171.  
  172. --
  173. Mitchell Spector
  174. spector@seattleu.edu
  175.  
  176.  
  177. ---------------------------
  178.  
  179. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  180. Subject: Copying with a mask
  181. Date: Sun, 20 Mar 1994 13:27:27 GMT
  182. Organization: Demon Internet
  183.  
  184.  
  185.      I'm looking for an efficient way to do a mask copy between offscreen
  186. graphics worlds. I have a solution which works, but it MUST be possible to
  187. do it faster!
  188.  
  189.      Here's the code (all variables are in registers, BTW):
  190.  
  191. if (*tMaskMemPtr++)
  192. {
  193.      *tDestMemPtr++ = *tSourceMemPtr++;
  194. } else
  195. {
  196.      *tDestMemPtr++;
  197.      *tSourceMemPtr++;
  198. }
  199.  
  200.      tMaskMemPtr, tDestMemPtr, and tSourceMemPtr are each pointers to chars
  201. to separate offscreen worlds (mask, destination, and source worlds,
  202. respectively).
  203.  
  204.      It's being done in 8-bit (so one byte/pixel), and the mask is either
  205. black or white. I'm checking the mask world pixel: if it's black, I'm
  206. copying the source pixel to the destination pixel; otherwise, I'm leaving
  207. the destination alone.
  208.  
  209.      I couldn't think of a way to do it using pointers to longs, but if
  210. there was a way it would be much faster! Anyone got any ideas? I'd prefer C
  211. code rather than assembler, but both are appreciated.
  212.  
  213.      Thanks,
  214.  
  215.  
  216.      Alex
  217.  
  218. --
  219. Alex Metcalf, Mac programmer in C, C++, HyperTalk, assembler
  220.  
  221. Internet, AOL, BIX: alex@metcalf.demon.co.uk            "Surely you
  222. AppleLink:          alex@metcalf.demon.co.uk@internet#   can't be
  223. CompuServe:         INTERNET:alex@metcalf.demon.co.uk    serious?"
  224. Delphi:             alex@metcalf.demon.co.uk@inet#
  225. FirstClass:         alex@metcalf.demon.co.uk,Internet   "I'm serious...
  226. Fax (UK):           (0570) 45636                         and don't call
  227. Fax (US / Canada):  011 44 570 45636                     me Shirley."
  228.  
  229. +++++++++++++++++++++++++++
  230.  
  231. >From al@crucible.powertools.com (Al Evans)
  232. Date: 20 Mar 94 16:54:42 GMT
  233. Organization: PowerTools, Austin, Texas
  234.  
  235. In article <alex-200394132815@metcalf.demon.co.uk> alex@metcalf.demon.co.uk (Alex Metcalf) writes:
  236.  
  237. >     I'm looking for an efficient way to do a mask copy between offscreen
  238. >graphics worlds. I have a solution which works, but it MUST be possible to
  239. >do it faster!
  240.  
  241. >     Here's the code (all variables are in registers, BTW):
  242.  
  243. >if (*tMaskMemPtr++)
  244. >{
  245. >     *tDestMemPtr++ = *tSourceMemPtr++;
  246. >} else
  247. >{
  248. >     *tDestMemPtr++;
  249. >     *tSourceMemPtr++;
  250. >}
  251.  
  252. >     tMaskMemPtr, tDestMemPtr, and tSourceMemPtr are each pointers to chars
  253. >to separate offscreen worlds (mask, destination, and source worlds,
  254. >respectively).
  255.  
  256. >     It's being done in 8-bit (so one byte/pixel), and the mask is either
  257. >black or white. I'm checking the mask world pixel: if it's black, I'm
  258. >copying the source pixel to the destination pixel; otherwise, I'm leaving
  259. >the destination alone.
  260.  
  261. >     I couldn't think of a way to do it using pointers to longs, but if
  262. >there was a way it would be much faster! Anyone got any ideas? I'd prefer C
  263. >code rather than assembler, but both are appreciated.
  264.  
  265. Well, this explanation will be more theoretical than practical, so I'm
  266. more likely to use assembly than C. To my knowledge, there are three
  267. ways to get "just the picture part" of a graphic overlaid into a
  268. background. One uses transparency, and two use masking.
  269.  
  270. The first way is similar to what you are doing now. In fact, if you
  271. guarantee that the "transparent" parts of your image will have some
  272. specified value (for example, 0), you can forego the mask entirely:
  273.  
  274.     if (*tSourceMemPtr) 
  275.         *tDestMemPtr++ = *tSourceMemPtr++;
  276.     else {
  277.         tSourceMemPtr++;
  278.         tDestMemPtr++;
  279.     }
  280.  
  281. The advantage of this approach is that it is memory-efficient. The
  282. disadvantage is that, as you have seen, it only works byte by byte.
  283. The only optimization I have found, in assembly, is to load the source
  284. a long word at a time and add 4 to the destination pointer if the
  285. result of the load is zero, thus avoiding the byte-by-byte check.
  286.  
  287. The second (and fastest) approach also presumes that you control the
  288. source graphics, and that the parts of these graphics to be masked
  289. are set to zero. In this approach, the mask is all zeros where the
  290. source graphic is "on", and all ones in the "transparent" portions.
  291. Under these conditions, you can do a long word as follows:
  292.  
  293.     MOVE.L    (destPtr), D0    ;get "background"
  294.     AND.L    (maskPtr)+, D0    ;keep only the part not covered by graphic
  295.     OR.L    (srcPtr)+, D0    ;add graphic
  296.     MOVE.L    D0, (destPtr)+    ;move to offscreen memory
  297.  
  298. The third (and most general) approach presumes only that you can
  299. make a mask covering the portions of the graphic you wish to transfer.
  300. In this case, the mask is all ones for the parts of the source graphic
  301. you want to copy, and all zeros where you want the background to
  302. show through. In assembly, the transfer looks like this:
  303.  
  304.     MOVE.L    (srcPtr)+, D0    ;Get long word of source
  305.     EOR.L    (destPtr), D0    ;D0 now XOR of source and dest
  306.     AND.L    (maskPtr)+, D0    ;Bkg part now all 0s
  307.     EOR.L     (destPtr), D0    ;Remove bkg bits from graphic while
  308.                 ;adding them to bkg part
  309.     MOVE.L    D0, (destPtr)+    ;move to offscreen memory
  310.  
  311. Of course, all of these transfer operations can be done the same
  312. way in C. I just think the assembly notation makes them more clear.
  313.  
  314.                     --Al Evans--
  315. -- 
  316.  
  317. Al Evans                         Tu causes, tu causes
  318. al@crucible.powertools.com               C'est tout ce que tu sais faire
  319. cs.utexas.edu!crucible!al                     -- LaVerdure
  320.  
  321. ---------------------------
  322.  
  323. >From johnsone@uxh.cso.uiuc.edu (Erik A. Johnson)
  324. Subject: Macsbug for PowerMac?
  325. Date: 17 Mar 1994 22:51:42 GMT
  326. Organization: University of Illinois at Urbana
  327.  
  328. Anyone know if Apple has a debugger (a la Macsbug) for the
  329. PowerMacs, either in existence, in development, or planned?
  330.  
  331.  
  332. Erik A. Johnson        \    Internet: johnsone@uxh.cso.uiuc.edu     \       |
  333. - ----------------------\    AmericaOnline: ErikAJ                   \    --+--
  334. Graduate Student         \--------------------------------------------\     |
  335. Aero/Astro Engineering    \  "Jesus said to him, 'I am the way, and    \    |
  336. University of Illinois at  \  the truth, and the life; no one comes to  \   |
  337.    Urbana-Champaign (UIUC)  \  the Father except through me.'" (Jn14:6)  \
  338.  
  339. +++++++++++++++++++++++++++
  340.  
  341. >From somogyi@macuser.ziff.com (Stephan Somogyi)
  342. Date: Fri, 18 Mar 1994 01:02:38 GMT
  343. Organization: MacUser Magazine US
  344.  
  345. In article <2mamtu$lfe@vixen.cso.uiuc.edu>, johnsone@uxh.cso.uiuc.edu
  346. (Erik A. Johnson) wrote:
  347.  
  348. > Anyone know if Apple has a debugger (a la Macsbug) for the PowerMacs,
  349. > either in existence, in development, or planned?
  350.  
  351. Macsbug works just fine on my Power Mac :-)
  352.  
  353. Apple has a 2-machine debugger for the Power Macs that once was called
  354. R2DB but now has a more whizzy and marketing-oriented name (Macintosh
  355. Debugger for PowerPC?). Metrowerks has a one-machine Power Mac debugger
  356. that comes with CodeWarrior. The current version of Jasik's Debugger also
  357. has a bunch of Power Mac support.
  358.  
  359. __________________________________________________________________________
  360. Stephan Somogyi           "...we shall never surrender."           MacUser
  361.  
  362. +++++++++++++++++++++++++++
  363.  
  364. >From ajr3@quads.uchicago.edu (Alain Roy)
  365. Date: Fri, 18 Mar 1994 02:56:20 GMT
  366. Organization: University of Chicago
  367.  
  368. In article <2mamtu$lfe@vixen.cso.uiuc.edu> johnsone@uxh.cso.uiuc.edu (Erik A. Johnson) writes:
  369. >Anyone know if Apple has a debugger (a la Macsbug) for the
  370. >PowerMacs, either in existence, in development, or planned?
  371.  
  372. believe it or not, macsbug will run on the power mac. i've seen it.
  373. of course, 68K disassembly and stack crawls are meaningless, but it works!
  374.  
  375. though it would be nice if they had "power macsbug" though could
  376. actually be useful for more than "es, rs and g"
  377.  
  378. -alain
  379.  
  380. +++++++++++++++++++++++++++
  381.  
  382. >From mlanett@netcom.com (Mark Lanett)
  383. Date: Fri, 18 Mar 1994 09:58:34 GMT
  384. Organization: Etch-a-Sketch Analysis and Design
  385.  
  386. somogyi@macuser.ziff.com (Stephan Somogyi) writes:
  387.  
  388. >In article <2mamtu$lfe@vixen.cso.uiuc.edu>, johnsone@uxh.cso.uiuc.edu
  389. >(Erik A. Johnson) wrote:
  390.  
  391. >> Anyone know if Apple has a debugger (a la Macsbug) for the PowerMacs,
  392. >> either in existence, in development, or planned?
  393.  
  394. >Macsbug works just fine on my Power Mac :-)
  395.  
  396. The slight problem with Macsbug, as I understand it, is that it's being
  397. emulated (!) and all the 601 stuff is done through dcmds, which makes
  398. them harder to use.
  399. -- 
  400.     Mark Lanett "Have a bajillion brillian Jobsian lithium licks"
  401.  
  402. +++++++++++++++++++++++++++
  403.  
  404. >From amanda@intercon.com (Amanda Walker)
  405. Date: Fri, 18 Mar 1994 16:58:10 -0500
  406. Organization: InterCon Systems Corporation, Herndon, VA USA
  407.  
  408. somogyi@macuser.ziff.com (Stephan Somogyi) writes:
  409. > Apple has a 2-machine debugger for the Power Macs that once was 
  410. > called R2DB but now has a more whizzy and marketing-oriented 
  411. > name (Macintosh Debugger for PowerPC?).
  412.  
  413. Yup.  It's not bad, but it's sllllooooowwwwwww.  What I wish I had is 
  414. something like TMON.  Not TMON Pro--the old small, fast TMON--but updated for 
  415. PowerPC debugging.  I don't even need source debugging if I can get fast
  416. stack crawls and breakpoints.
  417.  
  418. Sigh.
  419.  
  420.  
  421. Amanda Walker
  422. Advanced Projects
  423. InterCon Systems Corporation
  424.  
  425.  
  426.  
  427. +++++++++++++++++++++++++++
  428.  
  429. >From danprice@delphi.com
  430. Date: Sat, 19 Mar 94 00:37:37 -0500
  431. Organization: Delphi (info@delphi.com email, 800-695-4005 voice)
  432.  
  433.  
  434. Ouch!  Does Apple or Motorola plan to release a PPC debugger?  Howbout TMON or
  435. Jasik Systems?
  436.  
  437. Is there a PPC disassembler (like the old DisASM) yet?
  438.     -dp
  439.  
  440. ---------------------------
  441.  
  442. >From rang@winternet.mpls.mn.us (Anton Rang)
  443. Subject: Math on PowerMacs (was Re: PowerMac emulate a 68LC040??)
  444. Date: 19 Mar 1994 16:44:25 GMT
  445. Organization: Minnesota Angsters
  446.  
  447. In article <CMvs2q.Bw0@watserv2.uwaterloo.ca> grstate@zeus (Gavriel State) writes:
  448. >Extrapolating from this leads me to suspect that you might get as much 
  449. >as an 8x speedup over 040/FPU code, or 20-25x improvement over your 
  450. >IIci's 030/FPU. 
  451.  
  452.   Last night I wrote up a simple FP benchmark and ran it on a Quadra
  453. 700 (25MHz 68040) and the 8100.  I took a small (200x201) matrix and
  454. wrote up a quick Gaussian elimination by back-substitution routine.
  455. No optimizations, nothing fancy, just to get an idea of relative
  456. performance.  (I didn't test with SANE; everything was done with the
  457. FPU.)  Unfortunately the matrix would mostly fit in the L2 cache, so
  458. it's not a perfect way to compare performance on large arrays, but for
  459. what it's worth....
  460.  
  461. Times are in seconds.  TC = THINK C 6.0.1, MPW = MPW 3.3,
  462.                MW = Metrowerks 1.0a2,
  463.                SDK = Apple's SDK (Lucid compiler).
  464.  
  465.         Float        Double
  466.   Q700/MPW:    14.57        15.07
  467.   Q700/TC:     5.13         7.47
  468.   8100/MW:     1.07         1.14
  469.   8100/SDK:     0.83         0.72
  470.  
  471. A few remarks --
  472.  
  473.   MPW does very poorly because it doesn't strength-reduce the array
  474. indexing inside loops.  I think it might do that when "-opt full" is
  475. on, but MPW C 3.3 wouldn't generate correct code for this test unless
  476. I used "-opt on" instead.
  477.  
  478.   THINK C does a much better job, applying strength-reduction to the
  479. loops, and thus eliminating almost all integer multiplication.
  480.  
  481.   The Metrowerks compiler doesn't do strength reduction (or at least,
  482. I couldn't get it to), but apparently the 601's integer multiply isn't
  483. as slow as that of the 68040.  It wins on floating-point numbers, even
  484. though the 601 does all arithmetic internally in double precision.  My
  485. guess is that this is because the FP array fits in the L2 cache.
  486.  
  487.   The SDK compiler does a good job of optimization.  Not only does it
  488. do the basic strength reduction for the loops (and eliminate the
  489. now-unneeded induction variables), but it also unrolls the inner loop
  490. (though only in the single-precision case) and changes the operation
  491. inside the inner loop (a[i][j] <- a[i][j] - a[k][j]/F) into a
  492. multiply-negate-add instruction.
  493.  
  494.   So it looks like, even compared to a hypothetical 50MHz 68040
  495. machine, you'd get better performance on the 8100.  I didn't get a
  496. chance to try gcc or another highly optimizing compiler, but I doubt
  497. that it could perform more than a factor of two better on the '040, in
  498. the best case.
  499.  
  500.   I've added comp.sys.mac.programmer because of the compiler
  501. comparison; please followup to the appropriate group.
  502. --
  503. Anton Rang (rang@winternet.mpls.mn.us)
  504.  
  505. ---------------------------
  506.  
  507. >From gewekean@studentg.msu.edu (Andrew Geweke)
  508. Subject: Passing data through to completion procs?
  509. Date: Wed, 16 Mar 1994 22:06:40 -0500
  510. Organization: Michigan State University
  511.  
  512. What I'm doing is writing an interface library to MacTCP; I want it to be 
  513. simple. All routines are async, so I just want to have the caller pass in a 
  514. simple structure pointer; a field in the struct gets changed when the call 
  515. completes. I want to do this rather than having the user ravage through large 
  516. ParamBlocks and so forth for simplicity and so on.
  517.  
  518. My question is this: How can I get the Device Manager to pass four bytes to a 
  519. completion routine that I pass in when I make the call?
  520.  
  521. Basically, I'm having trouble getting a pointer to the structure through to 
  522. the completion routine. Is there any place I can stash this? I'm looking 
  523. through the ParamBlock structure right now, and everything's used or "not 
  524. used" (which, as we all know, means reserved -- I don't want to break rules 
  525. here).
  526.  
  527. Here are my ideas so far:
  528.  
  529. (1) Set the user up with a pointer to the ioResult field. Disadvantage: I 
  530. want to deallocate the parameter-block's memory as soon as the call 
  531. completes. This would require the user to do this.
  532.  
  533. (2) Create a linked list of all outstanding calls with pointers to their 
  534. parameter blocks. This is a roundabout method, though it should work; 
  535. however, I'd rather not.
  536.  
  537. Basically, I'm converting async calls from the beasts that they are into 
  538. simple ones; you pass in a struct with only the specific information that 
  539. gets a flag set when it's done. Any ideas?
  540.  
  541.  
  542.  
  543.  
  544.  
  545. +++++++++++++++++++++++++++
  546.  
  547. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  548. Date: Thu, 17 Mar 1994 01:37:49 -0600
  549. Organization: University of Illinois at Urbana-Champaign
  550.  
  551. In article <9403162206.AA40375@geweke.ppp.msu.edu>,
  552. gewekean@studentg.msu.edu (Andrew Geweke) wrote:
  553.  
  554. >What I'm doing is writing an interface library to MacTCP;
  555. >
  556. >My question is this: How can I get the Device Manager to pass four bytes to a 
  557. >completion routine that I pass in when I make the call?
  558. >
  559. >Basically, I'm having trouble getting a pointer to the structure through to 
  560. >the completion routine. Is there any place I can stash this?
  561.  
  562. Since you're using MacTCP, you're in luck. Every MacTCP param block has a
  563. userDataPtr field, which is exactly where you can store any pointer you
  564. like.
  565.  
  566. Even if this field weren't there, you can do the same thing. Just make
  567. your own personal parameter block which contains everything the real
  568. parameter block does, plus one pointer field tacked onto the end. The
  569. Device Manager and driver are only going to use the fields they specify,
  570. so this is perfectly safe. (How could it not be? It would be quite ugly if
  571. a device driver decided to use some memory past the end of its parameter
  572. block!)
  573.  
  574. pr
  575. -- 
  576. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  577. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  578. System manager - Cognitive Science Group, Beckman Institute, UIUC
  579. Internet: resnick@cogsci.uiuc.edu
  580.  
  581. +++++++++++++++++++++++++++
  582.  
  583. >From zben@ni.umd.edu (Charles B. Cranston)
  584. Date: 18 Mar 1994 00:50:47 GMT
  585. Organization: UMCP Network Infrastructures
  586.  
  587. In article <9403162206.AA40375@geweke.ppp.msu.edu>,
  588. gewekean@studentg.msu.edu (Andrew Geweke) wrote:
  589.  
  590. > What I'm doing is writing an interface library to MacTCP; I want it to be 
  591. > simple. All routines are async, so I just want to have the caller pass in a 
  592. > simple structure pointer; a field in the struct gets changed when the call 
  593. > completes. I want to do this rather than having the user ravage through large 
  594. > ParamBlocks and so forth for simplicity and so on.
  595.  
  596. > My question is this: How can I get the Device Manager to pass four bytes to a 
  597. > completion routine that I pass in when I make the call?
  598.  
  599. Another approach would be to erect a "trampoline" somewhere.  This would
  600. be 8 bytes consisting of a JSr to the real handler followed by the four
  601. data bytes.  The real handler immediately does a Move.L (A7)+,A0 and then
  602. A0 points to the four data bytes, and the stacktop is now the real final
  603. return address.
  604.  
  605. For MacTCP the UserData approach or the embed-IOPB-in-larger-known-block
  606. approaches would both work.  I am thinking about using this trampoline
  607. technique for EtherNet "Protocol Handlers" where the IOPB is not passed
  608. to the callback routine.
  609.  
  610. The cost, of course, is allocating and freeing the memory space for
  611. the trampoline, especially in the asynchronous environment you are
  612. talking about.
  613.  
  614. +++++++++++++++++++++++++++
  615.  
  616. >From markhanrek@aol.com (MarkHanrek)
  617. Date: 18 Mar 1994 12:52:03 -0500
  618. Organization: America Online, Inc. (1-800-827-6364)
  619.  
  620. A similar trick which works is to declare a data structure in which your custom
  621. info is first, and then you pass the address of the record field that is, say,
  622. four bytes from the actual beginning of the record structure to the
  623. asynchronous function.
  624.  
  625. There are situations, such as with the Time Manager, in which you are able to
  626. get the address of the parameter block the completion routine is passing in by
  627. grabbing the value in register A0, and then subtracting four from it to get at
  628. the specisl data value you've stashed.
  629.  
  630. It may be that this is "six of one - half-dozen of the other" with regard to
  631. Pete's excellent suggestion, but then maybe this is a uniform way of dealing
  632. with getting piggy-back data values that will work in every case regardless of
  633. the size of a given routine's parameter blocks.
  634.  
  635. Hope this helps.
  636.  
  637. Mark Hanrek
  638.  
  639.  
  640. +++++++++++++++++++++++++++
  641.  
  642. >From zben@ni.umd.edu (Charles B. Cranston)
  643. Date: 20 Mar 1994 18:41:43 GMT
  644. Organization: UMCP Network Infrastructures
  645.  
  646. In article <2mcpo3$qva@search01.news.aol.com>,
  647. markhanrek@aol.com (MarkHanrek) wrote:
  648.  
  649. > A similar trick which works is to declare a data structure in
  650. > which your custom info is first, and then you pass the address
  651. > of the record field that is, say, four bytes from the actual
  652. > beginning of the record structure to the asynchronous function.
  653.  
  654. Yes, this is exactly the "embed-IOPB-in-larger-known-block" solution
  655. that I alluded to in the article you followed up.  This works for
  656. the Time Manager, the Vertical Retrace Manager, and general IO.
  657. (Except maybe very early systems which don't pass the block in A0,
  658. I no longer remember the specifics.)
  659.  
  660. This works when the system is maintaining TWO pieces of information
  661. for you: the control block (IOPB, Time Manager Block, etc) *AND* the
  662. address of the completion routine.  When the system is only maintaining
  663. ONE piece of information for you (like the EtherNet driver's Protocol
  664. Handler, maybe also the LocalTalk driver's Protocol Handler) then the
  665. "trampoline" technique can be used to compress those two pieces of
  666. information (the REAL completion routine and the data value) into one
  667. (the trampoline's address).
  668.  
  669. > It may be that this is "six of one - half-dozen of the other" with regard to
  670. > Pete's excellent suggestion, but then maybe this is a uniform way of dealing
  671. > with getting piggy-back data values that will work in every case regardless of
  672. > the size of a given routine's parameter blocks.
  673.  
  674. Indeed, this is quite correct.  Also, I blew it when I said 8 bytes
  675. of information.  I believe the minimum would be 10 bytes:
  676.  
  677. 2 byte absolute JSR opcode
  678. 4 byte absolute address of the REAL completion routine
  679. 4 byte data or pointer to data
  680.  
  681. Typical dislexic problem.  Also see my short tip in this month's
  682. MacTutor where I conclude that a 16 bit word has 16384 possible
  683. values (and not 65536).  I'm suprised the editors didn't catch it.
  684.  
  685. Er, ah, that's MacTech magazine.  I'm so old I still say "Megacyles"...
  686. de KE3HE
  687.  
  688. ---------------------------
  689.  
  690. >From Laurent Humbert <laurent@humbert.demon.co.uk>
  691. Subject: Sending AppleEvents To Eudora
  692. Date: Sun, 20 Mar 1994 12:02:23 GMT
  693. Organization: QED Technology Ltd
  694.  
  695. Hi there,
  696.  
  697. In the application I am writting, I would need to tell
  698. Eudora to create a new message window, with a given To and Subject
  699. fields, as well as an initial content.
  700.  
  701. For the moment, I do just like Nuntius, bringing Eudora to the foreground,
  702. then calling PostEvent while I am in the background. Needless to say,
  703. this is a hack.
  704.  
  705. I am no AppleEvent manager expert, so if somebody has already written a
  706. routine
  707. that looks like
  708.  
  709. OSErr NewMessageInEudora( ProcessSerialNumber *eudoraPSN,
  710.                           Str255 to, Str255 subject,
  711.                           Handle initialcontent);
  712.  
  713. then I would be very interested (this is for a shareware application I am
  714. working on).
  715.  
  716. Thank you very much.
  717.  
  718. Laurent
  719.  
  720.                     o     o
  721.                      \|||/
  722. +----------------oOO-(o o)-OOo--------------+
  723. |   Laurent Humbert                         |
  724. |   Internet  : laurent@humbert.demon.co.uk |
  725. |   AppleLink : UK2001    CI$ : 100270,1136 |
  726. +-------------------------------------------+
  727.  
  728. +++++++++++++++++++++++++++
  729.  
  730. >From jonpugh@netcom.com (Jon Pugh)
  731. Date: Sun, 20 Mar 1994 19:49:30 GMT
  732. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  733.  
  734. Laurent Humbert (laurent@humbert.demon.co.uk) wrote:
  735.  
  736. > In the application I am writting, I would need to tell
  737. > Eudora to create a new message window, with a given To and Subject
  738. > fields, as well as an initial content.
  739.  
  740. I would consider using AppleScript's OSA layer to do this if you can get
  741. away with it.  It results in more flexible code since you can run a variety
  742. of scripts with it, whereas your Eduroa routine will only do one thing.
  743. The 2 routines will be about the same complexity to write.
  744.  
  745. Sorry I don't have details on your routine.
  746.  
  747. Jon
  748.  
  749.  
  750. ---------------------------
  751.  
  752. End of C.S.M.P. Digest
  753. **********************
  754.  
  755.  
  756.  
  757.